package cn.cjxy.service.impl;

import cn.cjxy.dao.IStudentDao;
import cn.cjxy.dao.impl.StudentDaoImpl;
import cn.cjxy.domain.Student;
import cn.cjxy.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class StudentServiceImpl implements IStudentService {
    //从IOC容器中取出对象
    @Resource//@Autowired
    private IStudentDao studentDao;


    @Override
    public void update(Student student) {
        Long id = student.getId();
        System.out.println(id);
        //调用dao层方法得到学生信息
        Student student1 = studentDao.getById(id);


        //执行业务操作
        student1.setName(student.getName());
        student1.setAge(student.getAge());
        student1.setSex(student.getSex());
        //调用dao层进行修改
        studentDao.update(student1);
    }
}
